<?php

class Admin_Model_GallerySizes {
	public $Id;
	public $Name;
	public $Width;
	public $Height;
	
	public function __construct($options = null)
    {
    	if ($options instanceof Admin_Model_GallerySizes)
    	{
    		$options = $options->toArray();
    		$this->setOptions($options);
    	}
        else if (is_array($options)) {
            $this->setOptions($options);
        }
    }
    
	public function setOptions(array $options){
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
        return $this;
    }
    
    public function toArray($onlyFields=false){
    	$vars = get_class_vars(get_class($this));
    	if ($onlyFields!=false)
    		$vars = array_intersect_key($vars,$onlyFields);
        foreach ($vars as $var=>$value)
        {
        		$vars[$var] = $this->$var;
        }
        return $vars;
    }

	public function getId(){return $this->Id;}
	public function getName(){return $this->Name;}
	public function getWidth(){return $this->Width;}
	public function getHeight(){return $this->Height;}
	
	public function setId($value){$this->Id = $value; return $this;}
	public function setName($value){$this->Name = $value; return $this;}
	public function setWidth($value){$this->Width = $value; return $this;}
	public function setHeight($value){$this->Height = $value; return $this;}
	
}

?>